package logutils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

public class OutputWriter {
	

	/*
	 * Dump 2 D integer array
	 */
	public static ArrayList<String> outIntArray(int[][] array, int d1, int d2,
			String heading, ArrayList<String> out) {
		String row;
		String a;
		//System.out.println(heading);
		out.add(heading);
		for (int i = 0; i < d1; i++) {
			row = Integer.toString(i) + " - ";
			for (int j = 0; j < d2; j++) {
				if (array[i][j] == -1) {
					a = "*";
				} else {
					a = Integer.toString(array[i][j]);
				}
				row = row + " : " + a;
			}
			//System.out.println(row);
			out.add(row);
		}
		return out;
	}

	/*
	 * Dump String, String Map
	 */
	public static ArrayList<String> outMapStrStr(HashMap<String, String> map,
			String keyname, String valuename, String heading,
			ArrayList<String> out) {
		Iterator<String> it;
		String key;
		//System.out.println(heading);
		out.add(heading);
		it = map.keySet().iterator();
		while (it.hasNext()) {
			key = it.next();
			//System.out.println(keyname + " ->" + key + " " + valuename + " "
			//		+ map.get(key));
			out.add(keyname + " ->" + key + " " + valuename + " "
					+ map.get(key));
		}
		return out;
	}
	/*
	 * Dump Integer, String Map
	 */
	public static ArrayList<String> outMapIntStr(HashMap<Integer, String> map,
			String keyname, String valuename, String heading,
			ArrayList<String> out) {
		Iterator<Integer> it;
		Integer key;
		//System.out.println(heading);
		out.add(heading);
		it = map.keySet().iterator();
		while (it.hasNext()) {
			key = it.next();
			//System.out.println(keyname + " ->" + key + " " + valuename + " "
				//	+ map.get(key));
			out.add(keyname + " ->" + key + " " + valuename + " "
					+ map.get(key));
		}
		return out;
	}
	/*
	 * Dump 1 D integer array
	 */
	public static ArrayList<String> outIntArrayD1(int[] array, String heading, ArrayList<String> out) {
		//System.out.println(heading);
		out.add(heading);
		for (int i = 0; i < array.length; i++) {
			//System.out.println(array[i]);
			out.add(Integer.toString(array[i]));
		}
		return out;
	}
	/*
	 * Dump a string
	 */
	public static ArrayList<String> stringDump(String description, String value, ArrayList<String> out){
		//System.out.println(description+" -> "+value);
		out.add(description+" -> "+value);
		return out;
	}
	public static ArrayList<String> comment(String val,ArrayList<String> out ) {
		//System.out.println("\n ---->"+val);
		out.add("\n------>"+val);
		return out;
	}
	
}
